package com.cheng.example.book.advise151.chap3;

/**
 * 建议35：避免在构造函数中初始化其它类
 *
 * 这导致了初始化的死循环
 */
public class Client35 {
    public static void main(String[] args) {
        Son son = new Son();
        son.doSomething();
    }
}

// 父类
class Father {
    public Father() {
        new Other();
    }
}

// 相关类
class Other {
    public Other() {
        new Son();
    }
}

// 子类
class Son extends Father {
    public void doSomething() {
        System.out.println("Hi, show me Something!");
    }
}